package util.comboloader;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.model.SelectItem;
import util.enumeration.IndustryType;
import util.enumhelper.LocalizedIndustryType;
import util.enumhelper.LocalizedPriceRange;
import util.localization.WebLocalization;

/**
 *
 * @author KohLi
 */
@ManagedBean(name = "enumIndustryType")
@RequestScoped
public class EnumIndustryType implements Serializable {
    
    private WebLocalization localization;
    //  user preferred locale
    private String preferredLocale;
    //The list with the items
    private List<SelectItem> listItems = null;

    /** Creates a new instance of enumindustry */
    
     public EnumIndustryType() {
        /* LOCALIZATION */
        localization = new WebLocalization();
        preferredLocale = localization.getPreferredLocaleFromSession();
        /* END LOCALIZATION */

        // load combobox
        loadCombo();
    }
    
      //Loading the items
    private void loadCombo() {
        setListItems(new ArrayList<SelectItem>());
        getListItems().add(new SelectItem(null, LocalizedSelect.getLocalizedSelectAsString(preferredLocale)));

        for (IndustryType i : IndustryType.values()) {
            String localizedIndustryType = LocalizedIndustryType.getLocalizedIndustryTypeAsString(i, preferredLocale);
            getListItems().add(new SelectItem(i, localizedIndustryType));
            
        }
    }

    /**
     * @return the listItems
     */
    public List<SelectItem> getListItems() {
        return listItems;
    }

    /**
     * @param listItems the listItems to set
     */
    public void setListItems(List<SelectItem> listItems) {
        this.listItems = listItems;
    }

    
}
